package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.FileSignLog;
import com.ruoyi.system.mapper.FileSignLogMapper;
import com.ruoyi.system.service.FileSignLogService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件签署日志表(FileSignLog)表服务实现类
 *
 * @author makejava
 * @since 2022-12-09 14:02:45
 */
@Service("fileSignLogService")
public class FileSignLogServiceImpl implements FileSignLogService {
    @Resource
    private FileSignLogMapper fileSignLogDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public FileSignLog queryById(Integer id) {
        return this.fileSignLogDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param fileSignLog 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<FileSignLog> queryByPage(FileSignLog fileSignLog, PageRequest pageRequest) {
        long total = this.fileSignLogDao.count(fileSignLog);
        return new PageImpl<>(this.fileSignLogDao.queryAllByLimit(fileSignLog, pageRequest), pageRequest, total);
    }

    @Override
    public List<FileSignLog> queryAll(FileSignLog fileSignLog) {
        return fileSignLogDao.queryAll(fileSignLog);
    }

    /**
     * 新增数据
     *
     * @param fileSignLog 实例对象
     * @return 实例对象
     */
    @Override
    public FileSignLog insert(FileSignLog fileSignLog) {
        this.fileSignLogDao.insert(fileSignLog);
        return fileSignLog;
    }

    /**
     * 修改数据
     *
     * @param fileSignLog 实例对象
     * @return 实例对象
     */
    @Override
    public FileSignLog update(FileSignLog fileSignLog) {
        this.fileSignLogDao.update(fileSignLog);
        return this.queryById(fileSignLog.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.fileSignLogDao.deleteById(id) > 0;
    }
}
